<?php
$this->breadcrumbs = array(
	'Quản lý Sự kiện',
);
?>
<!-- BEGIN PORTLET-->
<?php $form =$this->beginWidget('CActiveForm', array(
    'enableAjaxValidation'=>true,
)); ?>
<?php include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'toolbar/index.php'; ?>
<script>    
function reloadGrid(data) {
    $.fn.yiiGridView.update('slide-grid');
}
</script>
<div class="row">
	<div class="col-md-12">
    	<div class="portlet">
        	<div class="portlet-title">
            	<div class="caption"><i class="icon-bar-chart"></i>Danh sách sự kiện</div>
                <div class="actions">
                    	<?php echo CHtml::link('<span><i class="icon-plus"></i> Đăng sự kiện</span>', array('/Events/default/create'), array('class'=>'btn blue btn-sm')); ?>
                </div>
                <ul style="float:right;padding-right:5px">
                  <li class="btn-group">
                     <button type="button" class="btn blue dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-delay="1000" data-close-others="true">
                     <span>Actions</span> <i class="icon-angle-down"></i>
                     </button>
                     <ul class="dropdown-menu pull-right" role="menu">
                        <li><?php echo CHtml::ajaxSubmitButton('Activate',array('default/ajaxupdate','act'=>'doActive'), array('success'=>'reloadGrid'),array('class'=>'btn green','style'=>'margin-top: 3px;width: 100%;')); ?></li>
                        <li class="divider"></li>
                        <li><?php echo CHtml::ajaxSubmitButton('In Activate',array('default/ajaxupdate','act'=>'doInactive'), array('success'=>'reloadGrid'),array('class'=>'btn default','style'=>'margin-top: 3px;width: 100%;')); ?></li>
                        <li class="divider"></li>
                        <li><?php echo CHtml::ajaxSubmitButton('Delete',array('default/ajaxupdate','act'=>'doPendding'), array('success'=>'reloadGrid'),array('class'=>'btn red','style'=>'margin-top: 3px;margin-bottom: 3px;width: 100%;')); ?></li>
                     </ul>
                  </li>
              </ul>
            </div>
<div class="portlet-body">
	<?php $this->widget('zii.widgets.grid.CGridView', array(
		'id'=>'slide-grid',
		'dataProvider'=>$model->search(),
		'ajaxUpdate'=>true,
		'filter'=>$model,
		'itemsCssClass'=>'table table-striped table-bordered table-advance table-hover',
		'pager'=>array(
	        'header'=>'',
			'maxButtonCount'=>10,
	        'header'=>'',
	        'prevPageLabel'=>'<i class="icon-angle-left"></i></a>',
	        'nextPageLabel'=>'<i class="icon-angle-right"></i></a>',
	        'firstPageLabel'=>'First',
	        'lastPageLabel'=>'Last',
	        'footer'=>'',
			'selectedPageCssClass'=>'active',
			'hiddenPageCssClass'=>'disabled',
	        'htmlOptions'=>array(
	            'class'=>'pagination pagination-sm',
	        ),
	    ),
		'columns'=>array(
			array(
				'id'=>'autoId',
				'class'           => 'CCheckBoxColumn',
				'selectableRows'  => 20,
				),
			array(
				'name'=>'id',
				'value'=>'$data->id',
				'filter'=>''
			),
			array(
				'name'=>'title',
				'type'=>'raw',
        		'value'=>'CHtml::link($data->title,array("default/view","id"=>$data->id),array("target"=>"_blank"))',
			),
			array(
				'name'=>'status',
				'value'=>'$data->status',
				//'filter'=>array('A'=>'Hoạt động', 'I'=>'Ngừng hoạt động', 'P'=>'Chờ duyệt'),
				'filter'=>CHtml::activeDropDownList($model,"status",array(''=>'Trạng thái', 'A'=>'Hoạt động', 'I'=>'Ngừng hoạt động', 'P'=>'Chờ duyệt'), array("style"=>"width:50px !important;")),
			),
			array(
				'name'=>'posteddate',
				'value'=>'date("d-m-Y", strtotime($data->posteddate))',
				'filter'=>CHtml::activeTextField($model,"posteddate",array("style"=>"width:70px !important;")),
			),
			array(
				'name'=>'begintime',
				'value'=>'$data->getBegintime($data->startdate,$data->enddate)',
			),
			array(
				'name'=>'member_id',
				'value'=>'$data->getNameMember($data->member_id); ',
				'filter'=>CHtml::activeTextField($model,"member_id",array("style"=>"width:70px !important;")),
			),
			array(
				'name'=>'categoryId',
				'value'=>'(!empty($data->category->title)) ? $data->category->title : ""',
				'filter'=>CHtml::activeTextField($model,"categoryId",array("style"=>"width:70px !important;")),
			),
			array(
				'name'=>'numviews',
				'value'=>'$data->numviews',
				'filter'=>CHtml::activeTextField($model,"numviews",array("style"=>"width:30px !important;")),
				),
			array(
				'name'=>'countTicket',
				'value'=>'$data->getCountTicket($data->id)',
				'filter'=>CHtml::activeTextField($model,"countTicket",array("style"=>"width:30px !important;")),
			),
			array(
				'class'=>'CButtonColumn',
				'header'=>'Action',
				'template'=>'{updateseo} {view} {update} {delete}',
				'buttons'=>array
				(
//					'preview'=>array(
//						'label'=>'<i class="icon-file"></i>',
//						'imageUrl'=>false,
//						'url'=>'"http://nexttopevent.com/duyet-su-kien-" . $data->category->url . "/" . $data->url . ".html"',
//						'options'=>array(
//							'class'=>'btn default btn-xs red',
//							'title'=>'Preview',
//							'target'=>'_blank',
//						),
//					),

					'updateseo'=>array(
						'label'=>'<i class="icon-tag"></i>',
						'imageUrl'=>false,
						'url'=>'array("/Events/default/updateSeo", "id"=>$data->id)',
						'options'=>array(
							'class'=>'btn default btn-xs green',
							'title'=>'Update Seo',
						),
					),

					'view'=>array(
						'label'=>'<i class="icon-share"></i>',
						'imageUrl'=>false,
						'options'=>array(
							'class'=>'btn default btn-xs blue',
							'title'=>'View'
						),
					),
					'update'=>array(
						'label'=>'<i class="icon-edit"></i>',
						'imageUrl'=>false,
						'options'=>array(
							'class'=>'btn default btn-xs green',
							'title'=>'Edit'
						),
					),
					'delete'=>array(
						'label'=>'<i class="icon-trash"></i>',
						'imageUrl'=>false,
						'options'=>array(
							'class'=>'btn default btn-xs black',
							'title'=>'Delete'
						),
					),
				),
				'htmlOptions'=>array(
					'width'=>'100px',
					'class'=>'text-center'
				),
			),
		),
		'htmlOptions'=>array(
			'class'=>''
		),
	)); ?>
<?php $this->endWidget(); ?>
            </div>
        </div>
    </div>
</div>